package com.enzoism.springboot.dive.partitioningBy;

import com.enzoism.springboot.dive.model.UsrModel;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class A01PartitioningBy {
    public static void main(String[] args) {
        List<UsrModel> usrList = UsrModel.initList();
        // 场景一：按照Num进行Partition
        按照Num进行Partition(usrList);
    }

    private static void 按照Num进行Partition(List<UsrModel> usrList){
        Map<Boolean, List<UsrModel>> collect = usrList.stream().collect(Collectors.partitioningBy(x -> x.getUsrNum() > 1));
        for (Map.Entry<Boolean, List<UsrModel>> stringListEntry : collect.entrySet()) {
            System.out.println(stringListEntry.getKey() + "--->" + stringListEntry.getValue());
        }
    }
}
